package com.equipment;

import com.util.EncodingUtil;

/**
 * 发送读系统信息指令 FDA5 版本1.17
 * @version 1.18
 * @author 刘亚东
 *
 */
public class ReadSystemRequest {
	private String STX = "55AA"; // 帧开始标志
	private String RSCTL = "00"; // 串口帧序列号
	private String Length = ""; // 长度
	private String code = "FD"; // 代码
	private String broadening = "A5"; // 扩展代码
	private String BCC = ""; // 异或校验值
	private String ObuContractVersion = ""; // OBU合同版本号，0x00,0x10,0x11,0x12,0x16
	private String VendorType = ""; // 厂商类型，当OBU合同版本为0x00或0x10时该字段填写金逸02，聚利03，其它填写00
	private String SysInfoLen = ""; // 要读取的系统信息的长度

	public String command(String version, String type, String sysL) {
		this.ObuContractVersion = version;
		this.VendorType = type;
		SysInfoLen = EncodingUtil.desToHex(Integer.parseInt(sysL), 2);
		// -----------------------------------------------------------------------------
		Length = EncodingUtil.desToHex((broadening + ObuContractVersion
				+ VendorType + SysInfoLen).length() / 2, 4);
		// DATA由代码+扩展子代码+系统信息长度按顺序拼接组成
		String DATA = RSCTL + Length + code + broadening + ObuContractVersion
				+ VendorType + SysInfoLen;
		// 异或校验从RSCTL到DATA所有字节的异或值
		BCC = EncodingUtil.yihuo(EncodingUtil.change(DATA)).toUpperCase();
		String retn = STX + DATA + BCC; // 拼接完整的请求
		return retn;
	}

	public String getSTX() {
		return STX;
	}

	public void setSTX(String sTX) {
		STX = sTX;
	}

	public String getRSCTL() {
		return RSCTL;
	}

	public void setRSCTL(String rSCTL) {
		RSCTL = rSCTL;
	}

	public String getLength() {
		return Length;
	}

	public void setLength(String length) {
		Length = length;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getBroadening() {
		return broadening;
	}

	public void setBroadening(String broadening) {
		this.broadening = broadening;
	}

	public String getBCC() {
		return BCC;
	}

	public void setBCC(String bCC) {
		BCC = bCC;
	}

	public String getSysInfoLen() {
		return SysInfoLen;
	}

	public void setSysInfoLen(String sysInfoLen) {
		SysInfoLen = sysInfoLen;
	}

	public String getObuContractVersion() {
		return ObuContractVersion;
	}

	public void setObuContractVersion(String obuContractVersion) {
		ObuContractVersion = obuContractVersion;
	}

	public String getVendorType() {
		return VendorType;
	}

	public void setVendorType(String vendorType) {
		VendorType = vendorType;
	}

}
